<route lang="json5" type="page">
{
  layout: 'main',
  style: {
    navigationStyle: 'custom',
    navigationBarTitleText: '评测记录',
  },
}
</route>

<template>
  <view>
    <view v-for="(item, index) in evaluationRecord" :key="index">
      <SingleBenchmark :record="item" />
    </view>
  </view>
</template>

<script lang="ts" setup>
import { ref } from 'vue'
import { getSurveyResult } from '@/api/survey'
import { useUserStore } from '@/store/user'

// 定义 EvaluationRecord 接口
interface EvaluationRecord {
  name: string
  date: string
  score: number
  result: string
}

const userStore = useUserStore()

// 初始化 record 数据
const evaluationRecord = ref<EvaluationRecord[]>([])

onShow(() => {
  getSurveyResult({ userId: userStore.userInfo.openid }).then((res) => {
    console.log(res)
    evaluationRecord.value = res.data as EvaluationRecord[]
    evaluationRecord.value.forEach((item) => {
      // 本地时间
      item.date = new Date(item.date).toLocaleDateString()
    })
  })
})
</script>

<style lang="scss" scoped></style>
